Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ex01 exercise completed #92

Closed
wants to merge 6 commits into from
Closed

Conversation

MikeSullivan7
Copy link

Written as part of the Mantid New Starter exercises.

  • The code takes an ascii file as argument and counts the occurrences of unique words longer than 4 characters long.
  • The punctuation is removed, hyphenated words are split up, and the text is all made lowercase.
  • A check is run to catch an error if the ascii file cannot be found and informs the user that this is the case, the code then exits.
  • The code prints out the list of unique words and prints then in descending order of number of occurrences.
  • It is also possible to specify using the --lines flag to only print out the most frequent e.g. 10 words so that the command line isn't taken up by a long list of every word.
  • The code can be tested with the ascii file "Holmes.txt" in the exercise folder.

@MikeSullivan7
Copy link
Author

I have fixed the numpy issue by modifying the test workflow, however there is an Assertion Error:

AssertionError: Lists differ: ["Namespace(filename=['/home/runner/files/Holmes.txt'],", 'lines=None)'] != ['Word', 'Usage']

Looking into it now!

@MikeSullivan7
Copy link
Author

All tests for Ex_01 have passed!

Will start working on Exercise 2 now.

Copy link
Author

@MikeSullivan7 MikeSullivan7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made to pass python_tests

@MikeSullivan7
Copy link
Author

ex_02 has been completed with all checks passing.

  • The code has classes with a number of shapes with can be defined
  • each class knows its type, its number of sides and its lengths of each side.
  • the classes have methods to calculate their own perimeter and area, with a method to print out the information about each individual shape so they can be identified
  • a shape sorting class is defined which takes a list of shape objects as input and is able to print out the info on shapes which have a certain type or number of sides
  • methods also exist which can sort the list of shapes in descending area or perimeter and then print out the information accordingly
  • The code could potentially be improved by randomising the sides of each shape so the lists are different each time but wasn't sure it was completely necessary.

@MikeSullivan7 MikeSullivan7 force-pushed the mike_sullivan_exercises branch from 363ce72 to 7a325b9 Compare October 24, 2023 08:53
@MikeSullivan7 MikeSullivan7 force-pushed the mike_sullivan_exercises branch from 7a325b9 to 22ea60b Compare October 24, 2023 09:02
Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just need a few cleanups and tweaks.

exercises-python/mike_sullivan/ex01_basics/main.py Outdated Show resolved Hide resolved
exercises-python/mike_sullivan/ex01_basics/main.py Outdated Show resolved Hide resolved
exercises-python/mike_sullivan/ex01_basics/main.py Outdated Show resolved Hide resolved
exercises-python/mike_sullivan/ex02_oo_basics/main.py Outdated Show resolved Hide resolved
@MikeSullivan7
Copy link
Author

All suggested changes have been made

Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants